<template>
  <div class="recent-list">
    <ul>
      <li v-for="(item, index) in data" :key="index" @click="toArticle(item)">
        <div class="recent-item" v-if="item.data">
          <div>
            <img :src="item.data.icon" class="recent-img" />
          </div>
          <div class="info">
            <h3>{{ item.data.name }}</h3>
            <p>阅读进度：{{ item.title }}</p>
            <p>{{ item.data.desc }}</p>
          </div>
          <i></i>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: {
    data: Array
  },
  methods: {
    toArticle(item) {
      this.$router.push({
        name: 'articleView',
        params: {
          path: item.path,
          rootPath: item.rootPath,
          data: item.data
        }
      })
    }
  }
}
</script>

<style scoped>
.recent-list>ul>li {
  margin-left: 15px;
  position: relative;
  border-bottom: 1px solid #ddd;
}

.recent-list>ul>li:last-child {
  border: 0;
}

.recent-img {
  width: 76px;
  height: 100px;
  margin-right: 10px;
  border-radius: 4px;
  background: #f5f5f5;
}

.recent-item {
  display: flex;
  padding: 15px 0;
  font-size: 12px;
}

.recent-item .info {
  overflow: hidden;
  padding-right: 10px;
}

.recent-list .info>p {
  margin-bottom: 10px;
  color: #aaa;
}

.recent-list .info>p:first-of-type {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-list .info>p:last-of-type {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.recent-list .info>h3 {
  margin-bottom: 10px;
  font-weight: normal;
  font-size: 15px;
}
</style>